package com.jenings.shop.controller;

import com.jenings.shop.entity.SPCard;
import com.jenings.shop.service.SPCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = {"购物车gwc"})
@RestController
@RequestMapping("/gwcApi")
public class SPCardController {
    @Autowired
    SPCardService spCardService;
    //查询购物车所有商品
    @ApiOperation(value = "查询购物车所有商品")
    @RequestMapping(value = "/selectAll",method = RequestMethod.POST)
    public List<SPCard> selectAll(){
        List<SPCard> spCardList = spCardService.selectAll();
        return spCardList;
    }
    //修改购物车信息
    @ApiOperation(value = "修改购物车信息")
    @RequestMapping(value = "/updateByte", method = RequestMethod.POST, produces = "application/json")
    public boolean updateByte(@RequestBody SPCard spCard){
      //return spCardService.updateByte(spCard);
        System.out.println(spCard.getGwcId());
        return true;
    }

    //删除购物车信息
    @ApiOperation(value = "删除购物车信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gwcid", value = "购物车id", required = true, dataTypeClass = String.class)
    })
    @RequestMapping(value = "/delByte", method = RequestMethod.POST)
    public boolean delByte(@RequestParam(value = "gwcid") Integer gwcid){
        return spCardService.delByte(gwcid);
    }
    //添加购物车
    @RequestMapping(value = "/insertByte", method = RequestMethod.POST, produces = "application/json")
    public boolean insertByte(@RequestBody  SPCard spCard){
        return spCardService.insertByte(spCard);
    }
}
